package com.lagou.mr.homework;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortMapper extends Mapper<LongWritable, Text,SortBean, NullWritable> {

    // 获取SortBean对象
    SortBean bean = new SortBean();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String str = value.toString();
        // 封装bean
        bean.setId(1);
        bean.setNum(Long.parseLong(str));
        context.write(bean,NullWritable.get());
    }
}
